package com.ruoyi.stuclient.config.interceptor;

import com.alibaba.ttl.TransmittableThreadLocal;
import com.ruoyi.common.core.domain.ThirdSessionStudent;
import lombok.experimental.UtilityClass;

/**
 * @author
 * thirdSession工具类
 */
@UtilityClass
public class ThirdSessionHolder {

	private final ThreadLocal<ThirdSessionStudent> THREAD_LOCAL_THIRD_SESSION = new TransmittableThreadLocal<>();


	/**
	 * TTL 设置thirdSessionStudent
	 *
	 * @param thirdSessionStudent
	 */
	public void setThirdSessionStudent(ThirdSessionStudent thirdSessionStudent) {
		THREAD_LOCAL_THIRD_SESSION.set(thirdSessionStudent);
	}

	/**
	 * 获取TTL中的thirdSession
	 *
	 * @return
	 */
	public ThirdSessionStudent getThirdSessionStudent() {
		return THREAD_LOCAL_THIRD_SESSION.get();
	}

	public void clear() {
		THREAD_LOCAL_THIRD_SESSION.remove();
	}

}
